#region BLL VERSION  2.6
/* DoiTuong
 *
 * Author: LANNT    
 * Copyright: (c) - LANNT 
 * Created:   13/09/2012 1:16:02 PM
 * Last modify: 2012-08-01 11:15 PM 
 * Note   :   Changes to this file may cause incorrect behavior and will be lost if
*            the code is regenerated.
*/
#endregion

#region Using directives
using System;
using System.Collections;
using System.Collections.Generic;
using GQ.Utils;

using Chili.Opf3;
using Chili.Opf3.Relations;
using Chili.Opf3.DynamicProperties;
#endregion

namespace GQ.BLL.QuanLyKho
{
	#region DoiTuong
	[Serializable]
	[Persistent("DOITUONG", PoolSize = 10)]
	public partial class DoiTuong 
	{
		#region Members
		private Guid _id=Guid.NewGuid();
		private string _ma=null;
		private string _ten=null;
		private Guid? _companyid=null;
		private string _diachi=null;
		private string _masothue=null;
		private string _dienthoai=null;
		private string _fax=null;
		private string _email=null;
		private string _website=null;
		private string _taikhoannganhang=null;
		private string _tennganhang=null;
		private string _ghichu=null;
		private bool? _istochuc=null;
		private int? _loaidoituong=null;
		private decimal? _notoida=null;
		private int? _hanno=null;
		#endregion
		
		#region Public Properties
		
		[Field("ID", Identifier=true, AllowDBNull=false)]
		public Guid ID
		{
			get{ return _id; }
			set{ _id = value; }
		}
		
		[Field("MA")]
		public string Ma
		{
			get{ return _ma; }
			set{ _ma = value; }
		}
		
		[Field("TEN")]
		public string Ten
		{
			get{ return _ten; }
			set{ _ten = value; }
		}
		
		[Field("COMPANYID")]
		public Guid? CompanyID
		{
			get{ return _companyid; }
			set{ _companyid = value; }
		}
		
		[Field("DIACHI")]
		public string DiaChi
		{
			get{ return _diachi; }
			set{ _diachi = value; }
		}
		
		[Field("MASOTHUE")]
		public string MaSoThue
		{
			get{ return _masothue; }
			set{ _masothue = value; }
		}
		
		[Field("DIENTHOAI")]
		public string DienThoai
		{
			get{ return _dienthoai; }
			set{ _dienthoai = value; }
		}
		
		[Field("FAX")]
		public string Fax
		{
			get{ return _fax; }
			set{ _fax = value; }
		}
		
		[Field("EMAIL")]
		public string Email
		{
			get{ return _email; }
			set{ _email = value; }
		}
		
		[Field("WEBSITE")]
		public string Website
		{
			get{ return _website; }
			set{ _website = value; }
		}
		
		[Field("TAIKHOANNGANHANG")]
		public string TaiKhoanNganHang
		{
			get{ return _taikhoannganhang; }
			set{ _taikhoannganhang = value; }
		}
		
		[Field("TENNGANHANG")]
		public string TenNganHang
		{
			get{ return _tennganhang; }
			set{ _tennganhang = value; }
		}
		
		[Field("GHICHU")]
		public string GhiChu
		{
			get{ return _ghichu; }
			set{ _ghichu = value; }
		}
		
		[Field("ISTOCHUC")]
		public bool? IsToChuc
		{
			get{ return _istochuc; }
			set{ _istochuc = value; }
		}
		
		/// <summary>
		/// 0 khach hang, 1 nha cung cap, 2 khach hang va nha cung cap.
		/// </summary>
		[Field("LOAIDOITUONG")]
		public int? LoaiDoiTuong
		{
			get{ return _loaidoituong; }
			set{ _loaidoituong = value; }
		}
		
		[Field("NOTOIDA")]
		public decimal? NoToiDa
		{
			get{ return _notoida; }
			set{ _notoida = value; }
		}
		
		[Field("HANNO")]
		public int? HanNo
		{
			get{ return _hanno; }
			set{ _hanno = value; }
		}
		
		#endregion
		#region Methods Install
		public DoiTuong LoadByID()
		{
		   return DbContext.ObjectContext.GetObject<DoiTuong>("ID={0}",ID);
		}
		public static DoiTuong LoadByID(Guid id)
		{
		   return DbContext.ObjectContext.GetObject<DoiTuong>("ID={0}",id);
		}
		public void DeleteByID(Guid id)
		{
		   ID=id;
		   Chili.Opf3.ObjectInfo  objInfo= GQ.Utils.DbContext.ObjectContext.GetObjectInfo(this);
			  objInfo.ObjectState = Chili.Opf3.ObjectStates.Loaded;
			  objInfo.MarkForDeletion = true;
		   DbContext.ObjectContext.PersistChanges<DoiTuong>(this);
		}
		public DoiTuong LoadBy(string conditions, params object[] parameter)
		{
		   return DbContext.ObjectContext.GetObject<DoiTuong>(conditions, parameter);
		}
		public void Save()
		{
		   DbContext.ObjectContext.PersistChanges<DoiTuong>(this);
		}
		public void Delete()
		{
			 DbContext.ObjectContext.MarkForDeletion(this);
		   DbContext.ObjectContext.PersistChanges<DoiTuong>(this);
		}
		#endregion Methods Install
		#region Methods Collection
		public static IList<DoiTuong> LoadAll()
		{
		   return DbContext.ObjectContext.GetObjectSet<DoiTuong>();
		}
		public static IList<DoiTuong> LoadAll(string sortby)
		{
		   return DbContext.ObjectContext.GetObjectSet<DoiTuong>("Sortby " + sortby);
		}
		public static IList<DoiTuong> LoadAllBy(string conditions, params object[] parameter)
		{
		   return DbContext.ObjectContext.GetObjectSet<DoiTuong>(conditions, parameter);
		}
		public static IList<DoiTuong> LoadAllBy(Chili.Opf3.Query.SqlQuery query)
		{
		   return DbContext.ObjectContext.GetObjectSet<DoiTuong>(query);
		}
		public static void SaveAll(IList<DoiTuong> collection)
		{
		   foreach (DoiTuong item in collection)
		   {
		       item.Save();
		   }
		}
		public static void DeleteAll(IList<DoiTuong> collection)
		{
			foreach (DoiTuong item in collection)
			{
		 		item.Delete();
			}
		}
		#endregion Methods Collection

	}
	#endregion
	
}
